﻿/*
 *Author: Jeff Liu 
 *
 *Under MIT License
 *jebberwocky@gmail.com
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CtpGglPlaces.Impl;
using CtpGglPlaces.Interface;
using CtpGglPlaces.Core;

namespace CtpGglPlaces
{
    public class Searcher
    {
        public static PlacesResult GetPlaces(SearchUrlParameter info, string format)
        {
            if (info == null)
                return null;

            IPlaceParser parser = null;
            if ("json".Equals(format))
                parser = new JsonPlaceParser();
            else
                throw new NotSupportedException();

            String resultText = GooglePlacesApi.SendRequest(info, format);
            PlacesResult result = parser.Parse(resultText);
            return result;
        }

        public static PlaceDetailsResult GetDetail(DetailUrlParameter info, string format)
        {
            if (info == null)
                return null;

            IPlaceDetailsParser parser = null;
            if ("json".Equals(format))
                parser = new JsonPlaceDetailsParser();
            else
                throw new NotSupportedException();

            String resultText = GooglePlacesApi.SendRequest(info, format);
            PlaceDetailsResult result = parser.Parse(resultText);
            return result;
        }
    }

}
